<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>nodeName,nodeValue</title>
  </head>
  <body>
    <!--nodeName,nodeValue-->
    <div id="container">这是一个元素节点</div>
    <script>
      var documentCount = 0;
      /**
      * 使用log方法打印出此页面包含的所有节点的 nodeName 和 nodeType (换行符除外)
      **/

      var divElement = document.getElementById("container");
      log("div ",divElement);

      console.log("共有node节点："+documentCount+"个");


      function log(explanation,node){
        var strArr = [];
        strArr.push("节点位置: [ "+explanation+" ]");
        strArr.push("节点名字: "+node.nodeName);
        strArr.push("节点类型: "+node.nodeType);
        documentCount++;
        console.log(strArr.join("  "));
      }
      
    </script> 
  </body>
</html>